from flask import Blueprint, Flask, request
from VisaManager import vm

DCPower = Blueprint('DCPower', __name__)
address: str = 'TCPIP0::192.168.0.222::inst0::INSTR'
vm.add_resource(address)


@DCPower.route('/TC001', methods=['POST'])
def index():
    state = request.args.get('state')
    command_visa = f"OUTP {state}"
    vm.write(command_visa)
    return "Welcome to the Home Page!"


@DCPower.route('/hello')
def hello():
    return "Hello, World!"


if __name__ == '__main__':
    app = Flask(__name__)
    app.register_blueprint(DCPower)
    app.run()
